package com.logistics.modules.transportationManagement.dao;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logistics.modules.transportationManagement.chart.KeyAndValueChart;
import org.apache.ibatis.annotations.Param;

import com.logistics.modules.transportationManagement.entity.MoveplanEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

/**
 * 
 * 
 * @author HURRICANE
 * @email HURRICANE@nb.com
 * @date 2022-05-14 10:48:35
 */
@Mapper
public interface MoveplanDao extends BaseMapper<MoveplanEntity> {

    /**
     * 分页查询页面
     *
     * @param page 页面
     * @param status
     * @return {@link IPage}<{@link MoveplanEntity}>
     */
    IPage<MoveplanEntity> quaryPage(@Param("page") IPage<MoveplanEntity> page,
                                    @Param("name") String name,
                                    @Param("phone") String phone,
                                    @Param("planMoney") Integer planMoney,
                                    @Param("planStatus") Integer planStatus,
                                    @Param("planCargoStatus") Integer planCargoStatus,
                                    @Param("startAddress") String startAddress,
                                    @Param("endAddress") String endAddress,
                                    @Param("status") Boolean status);

    /**
     * 更新运费表id, id
     *
     * @param frightId 恐惧id
     * @param id       id
     * @return int
     */
    int updateFrightIdById(@Param("frightId") Integer frightId, @Param("id") Integer id);

    /**
     * 选择一个通过id
     *
     * @param id id
     * @return {@link MoveplanEntity}
     */
    MoveplanEntity selectOneById(@Param("id") Integer id);

    /**
     * 根据id选择所有
     *
     * @param ids id
     * @return {@link List}<{@link MoveplanEntity}>
     */
    List<MoveplanEntity> selectAllByIds(@Param("ids") Integer[] ids);

    /**
     * 更新货物状态id
     *
     * @param cargoStatus 货物状态
     * @param id          id
     * @return int
     */
    int updateCargoStatusById(@Param("cargoStatus") Integer cargoStatus, @Param("id") Integer id);

    int updatePlanStatusAndCloseStatusAndFinishTimeById(@Param("planStatus") Integer planStatus, @Param("closeStatus") Integer closeStatus, @Param("finishTime") Date finishTime, @Param("id") Integer id);

    /**
     * 根据日期查询总金额
     *
     * @param day 一天
     * @return {@link Double}
     */
    List<String> selectSumMoneyByDate(@Param("day") Integer day);

    /**
     * 根据年份查询数据
     */
    List<KeyAndValueChart> selectSumMoneyByYear();

    int countByPlanStatusAndUndone();

    int countByPlanStatusAndFinish(@Param("planStatus") Integer planStatus);

    /**
     * 查询全部年份的数据
     */
    List<KeyAndValueChart> selectSumMoneyByAllYear();

}
